package com.bright.cwduijie.common.config;

import com.bright.cwduijie.common.util.StringUtil;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

@Slf4j
public class BooleanStringDeserializer extends JsonDeserializer<String> {
 
    @Override
    public String deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {

        log.debug("进入反序列化方法");
        if (StringUtil.equals(jp.getText(), "0.00") || StringUtil.equals(jp.getText(), "0.0") || StringUtil.equals(jp.getText(), "0")) {
            return null;
        }
        return jp.getText();
    }
}